package cn.tedu.exercise;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author :Colin
 * @version 创建时间: 2021/7/2 19:40
 */
public class Exercise2 {
    public static void main(String[] args) throws Exception {
        //1.drive
        Class.forName("com.mysql.jdbc.Driver");
        //2.connect
        String url="jdbc:mysql://localhost:3306/colinbase";
        Connection conn = DriverManager.getConnection(url, "root", "root");
        //3.statement
        Statement st= conn.createStatement();
        //4.sql语句
        String sql="create table MY_DOG (name varchar(10) ,age int primary key auto_increment,addr varchar(200))";
        String sql1="alter table MY_DOG add column gender varchar(3) ";
        String sql2="insert into MY_DOG values('Punk',null,'taiyuan','boy'),('Punk2',null,'taiyuan','boy')";
        int tb = st.executeUpdate(sql);
        System.out.println(tb);
        int tb1 = st.executeUpdate(sql1);
        System.out.println(tb1);
        int tb2 = st.executeUpdate(sql2);
        System.out.println(tb2);
        System.out.println("succeed");
        st.close();
        conn.close();

    }
}
